package cn.com.dashihui.web.service;

import java.util.List;

import com.jfinal.plugin.activerecord.Db;

import cn.com.dashihui.web.dao.GoodsEge;
import cn.com.dashihui.web.dao.WxGoodsTitle;

public class WxGoodsTitleService {
	
	public boolean addCategory(WxGoodsTitle newObject){
		return newObject.save();
	}
	
	public boolean delCategory(int id){
		return WxGoodsTitle.me().deleteById(id);
	}
	
	public boolean editCategory(WxGoodsTitle object){
		return object.update();
	}
	
	public WxGoodsTitle findById(int id){
		return WxGoodsTitle.me().findFirst("SELECT * FROM t_bus_goods_title WHERE id=?",id);
	}

	public List<WxGoodsTitle> findAll(){
		return WxGoodsTitle.me().find("SELECT A.* FROM t_bus_goods_title A  ORDER BY A.id DESC");
	}
	/**
	 * 查询标签下的商品
	 */
	public List<GoodsEge> findGoodsByTitle(String lableId){
		return GoodsEge.me().find("SELECT * FROM t_bus_ege_goods WHERE lableId = ?",lableId);
	}
	/**
	 * 删除商品的标签Id
	 */
	public int deleteEgeLableId(int egeId){
		return Db.update("update  t_bus_ege_goods set lableId = 0 WHERE id = ?",egeId);
	}
}
